package com.sk.ccflower.server.lib.dbUtils.sql;

import java.util.ArrayList;

import com.sk.ccflower.lib.define.DBTable;
import com.sk.ccflower.lib.meBeans.ShareInfoBean;
import com.sk.ccflower.server.lib.dbBeans.CfProfileShareBean;
import com.sk.ccflower.server.lib.dbUtils.SQLReturn;

public class CfProfileShareSql extends BaseSql {
	
	private static final String m_column = "profile_share_idx, src_user, dest_user, s_type, s_date";
	private static final String m_column_insert = "src_user, dest_user, s_type";
	
	private static final String m_basequery = "SELECT " + m_column + " FROM " + DBTable.CF_PROFILE_SHARE;
	private static String m_insertQuery = null;
	
	static {
		m_insertQuery = makeInsertSql(DBTable.CF_PROFILE_SHARE, m_column_insert);
	}
	
	public CfProfileShareSql() throws Exception {
		super( CfProfileShareBean.class, "src_user", "dest_user" );		
	}
	
	@Override
	protected void clearOtherHash() {
		// TODO Auto-generated method stub
	}

	@Override
	protected void initKeyFields() throws Exception {
		// TODO Auto-generated method stub
	}

	@Override
	protected void putInOtherHash(Object data) throws Exception {
		// TODO Auto-generated method stub
	}
	
	public static SQLReturn getSql() {
        SQLReturn sret = new SQLReturn();
        
        sret.m_query = m_basequery;
        sret.m_params = new ArrayList<Object>();
        sret.m_class = CfProfileShareBean.class;
        sret.m_colMap = null;
        
        return sret;
    }
	
	public static SQLReturn getSql( String src_user, String dest_user ) {
        SQLReturn sret = new SQLReturn();
        
        sret.m_query = m_basequery + " WHERE src_user=? AND dest_user=?";
        sret.m_params = new ArrayList<Object>();
        sret.m_class = CfProfileShareBean.class;
        sret.m_colMap = null;
        sret.m_params = new ArrayList<Object>();
        sret.m_params.add(src_user);
        sret.m_params.add(dest_user);
        
        return sret;
    }
	
	public static SQLReturn getSqlInsert( CfProfileShareBean _bean ) {
		SQLReturn ret = new SQLReturn();
		
		ret.m_query = m_insertQuery;
		ret.m_class = CfProfileShareBean.class;
		ret.m_colMap = null;
		ret.m_params = new ArrayList<Object>();
		ret.m_params.add(_bean.src_user);
		ret.m_params.add(_bean.dest_user);
		ret.m_params.add(_bean.s_type);
		
		return ret;
	}
	
	public static SQLReturn getSqlDelete( ShareInfoBean bean ) {
    	SQLReturn sret = new SQLReturn();
    	
    	sret.m_query = "DELETE FROM " + DBTable.CF_PROFILE_SHARE + " WHERE src_user=? AND dest_user=? AND s_type=?";
        sret.m_class = CfProfileShareBean.class;
        sret.m_colMap = null;
        sret.m_params = new ArrayList<Object>();
        sret.m_params.add( bean.src_user );
        sret.m_params.add( bean.dest_user );
        sret.m_params.add( bean.s_type );
    	
        return sret;
    }
	
}
